<!DOCTYPE HTML>
<html>
<head>
    <!-- support for mobile touch devices -->
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">

    <!-- twitter bootstrap CSS stylesheet - not required by cornerstoneTools -->
    <link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">

    <link href="../cornerstone.min.css" rel="stylesheet">

</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>
            Highlight Tool Example
        </h1>
        <p>
            This page contains an example of the highlight tool
        </p>

    </div>

    <div class="row">
        <div class="col-xs-2">
            <ul class="list-group">
                <a id="disable" class="list-group-item">Disable</a>
                <a id="enable" class="list-group-item">Enable</a>
                <a id="activate" class="list-group-item">Activate</a>
                <a id="deactivate" class="list-group-item">Deactivate</a>
            </ul>
        </div>
        <div class="col-xs-6">
            <div style="width:512px;height:512px;position:relative;display:inline-block;color:white;"
                 oncontextmenu="return false"
                 class='cornerstone-enabled-image'
                 unselectable='on'
                 onselectstart='return false;'
                 onmousedown='return false;'>
                <div id="dicomImage"
                     style="width:512px;height:512px;top:0px;left:0px; position:absolute;">
                </div>
            </div>
        </div>

    </div>

</body>

<!-- include the cornerstone library -->
<script src="../cornerstone.min.js"></script>
<script src="../cornerstoneMath.min.js"></script>

<!-- include the cornerstone tools library -->
<script src="../../dist/cornerstoneTools.js"></script>
<script>window.cornerstoneTools || document.write('<script src="https://unpkg.com/cornerstone-tools">\x3C/script>')</script>

<!-- include special code for these examples which provides images -->
<script src="../exampleImageLoader.js"></script>

<script>
    var element = document.getElementById('dicomImage');

    var imageId = 'example://1';

    // image enable the dicomImage element
    cornerstone.enable(element);
    cornerstoneTools.mouseInput.enable(element);

    cornerstone.loadImage(imageId).then(function(image) {
        cornerstone.displayImage(element, image);

        // Enable all tools we want to use with this element
        cornerstoneTools.highlight.activate(element, 1);
        activate("activate");

        function activate(id)
        {
            document.querySelectorAll('a').forEach(function(elem) { elem.classList.remove('active'); });
            document.getElementById(id).classList.add('active');
        }

        // Tool button event handlers that set the new active tool
        document.getElementById('disable').addEventListener('click', function() {
            activate("disable");
            cornerstoneTools.highlight.disable(element);
            return false;
        });
        document.getElementById('enable').addEventListener('click', function() {
            activate("enable");
            cornerstoneTools.highlight.enable(element);
            return false;
        });
        document.getElementById('activate').addEventListener('click', function() {
            activate("activate");
            cornerstoneTools.highlight.activate(element, 1);
            return false;
        });
        document.getElementById('deactivate').addEventListener('click', function() {
            activate("deactivate");
            cornerstoneTools.highlight.deactivate(element, 1);
            return false;
        });
    });



</script>
</html>
